home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Visual Database / Visual dBase v5.5 / SAMPINC.PAK / DBASEEXT.H next >
C/C++ Source or Header  |  1995-07-18  |  6KB  |  183 lines

  1. //
  2. // $Revision:   2.9  $
  3. //
  4. // dBASE extensions.
  5. //
  6.  
  7. #ifndef __DBASEEXT_H__
  8.  
  9. #define DBEXPORT _cdecl _loadds
  10. #define FARVTABLE _huge
  11.  
  12. #define DBEXTERR int
  13.  
  14. class CSession;
  15.  
  16. #ifndef DBaseVar
  17. class DBaseVar;
  18. typedef long double DoubleType;
  19. #endif
  20.  
  21. //
  22. // Dlls export this function. This function is called every time an Instance
  23. //  of dBASE loads the DLL.  If for some reason the DLL detirmines that it
  24. //  cannot load, it can return an error.  If the DLL loads properly it should
  25. //  return DBASE_INIT_OK.
  26. //
  27. extern "C" int CALLBACK DBaseInitInstance(void);
  28.  
  29. #define DBASE_INIT_OK                  0     // init
  30. #define DBASE_INIT_NO_MULTI_INSTANCE   1     // dll can't support multi instance
  31. #define DBASE_INIT_VBX_LOAD_FAIL       2     // VBX failed to load (message already put up by .VBX)
  32. #define DBASE_INIT_ERROR               -1    // error occured loading DLL
  33.  
  34. //
  35. // DBaseExitInstance() is called when an instance of dBASE terminate or manually
  36. //  unloads a DLL through the RELEASE DLL command.  This give the DLL a chance
  37. //  to free any resources associated with a running instance.
  38. //
  39. extern "C" void CALLBACK DBaseExitInstance(void);
  40.  
  41. //
  42. // class DBaseExtension is an abstract base class (virtual function definitions
  43. //  only, not implementation) with callbacks into the dBASE executable.  A
  44. //  pointer to this class is retrieved through a call the the function DBase().
  45. //
  46. // Using this virtual call mechanism, a DLL can call into dBASE without getting
  47. //   procedure addresses.
  48. //
  49. class FARVTABLE DBaseExtension {
  50. public:
  51.    //
  52.    // Supplied for future expandability.  Returns pointer to an abstract
  53.    //  base class.
  54.    //
  55.    virtual void* DBEXPORT Supports(int interfaceId)=0;
  56.  
  57.    //
  58.    // Get the version number of this interface.  This class is designed to be
  59.    //  extended over time.  Each time the interface is extended, the version
  60.    //  label is bumped.
  61.    //
  62.    virtual WORD DBEXPORT GetExtensionVersion()=0;
  63.  
  64.    //
  65.    // Set the session pointer for the current session.  This call is a
  66.    //  convienance to the DLL programmer.  The DLL programmer can create an
  67.    //  instance of class CSession in the DBaseInitInstance() and set it.
  68.    //  In subsequent call backs, this session pointer can be retrieved with
  69.    //  a call to GetSession().  Data that is kept on a per-instance basis
  70.    //  (DBaseVars for example) should be kept in the session object.
  71.    //
  72.    virtual void DBEXPORT SetSession(CSession *pSession)=0;
  73.    virtual CSession* DBEXPORT GetSession(void)=0;
  74.  
  75.    //
  76.    // Get a string representation of the Last Error that Occured
  77.    //
  78.    virtual char * DBEXPORT GetError()=0;
  79.  
  80.    //
  81.    // Set an error to display
  82.    //
  83.    virtual void DBEXPORT SetError(char *)=0;
  84.  
  85.    //
  86.    // Stop the thread of execution that has called this function.
  87.    //
  88.    virtual void DBEXPORT ReturnError()=0;
  89.  
  90.    //
  91.    // Variable Manipulation functions
  92.    //
  93.    virtual DBaseVar* DBEXPORT MakeVar()=0;
  94.    virtual void DBEXPORT DestroyVar(DBaseVar*)=0;
  95.  
  96.    //
  97.    // Returns a pointer to the variable THIS.  If null is returned, the
  98.    //  current execution context is a function, not a method.  Though there
  99.    //  are not protections, one should never write to the variable THIS.
  100.    //
  101.    virtual DBaseVar* DBEXPORT GetThis()=0;
  102.  
  103.    //
  104.    // Returns the type of a dbase variable.
  105.    //  return values
  106.    //    'L'   = Logical
  107.    //    'N'   = Numeric (floating point DoubleType)
  108.    //    'I'   = Integer Numeric
  109.    //    'C'   = String
  110.    //    'D'   = Date
  111.    //    'O'   = Object
  112.    //    'P'   = Codeblock or function
  113.    //    'M'   = Memo
  114.    //    'B'   = BookMark
  115.    //
  116.    virtual char DBEXPORT VarGetType(DBaseVar*)=0;
  117.  
  118.    //
  119.    // Retrieves binary value from variable.
  120.    //
  121.    virtual DBEXTERR DBEXPORT VarGetLogical(DBaseVar*, BOOL *pDest)=0;
  122.    virtual DBEXTERR DBEXPORT VarGetDouble(DBaseVar*, DoubleType *pDest)=0;
  123.    virtual DBEXTERR DBEXPORT VarGetLong(DBaseVar*, long *pDest)=0;
  124.    virtual DBEXTERR DBEXPORT VarGetString(DBaseVar*, char**ppDest)=0;
  125.    virtual DBEXTERR DBEXPORT VarGetStringLen(DBaseVar*, int*)=0;
  126.    virtual DBEXTERR DBEXPORT VarGetProperty( DBaseVar* pObj, char* pPropertyName,
  127.             DBaseVar* pDest )=0;
  128.  
  129.    virtual DBEXTERR DBEXPORT VarGetElement(DBaseVar* pArray,DBaseVar*pDest,
  130.             int iDimCount, DBaseVar**)=0;
  131.  
  132.    virtual DBEXTERR DBEXPORT VarRunCode(DBaseVar *pSrc,DBaseVar *pDest,
  133.             int iParaCount,DBaseVar**)=0;
  134.  
  135.    virtual void DBEXPORT VarSetLogical(DBaseVar*, BOOL)=0;
  136.    virtual void DBEXPORT VarSetDouble(DBaseVar*, DoubleType)=0;
  137.    virtual void DBEXPORT VarSetLong(DBaseVar*, long)=0;
  138.  
  139.    virtual void DBEXPORT VarSetZString(DBaseVar*, char* pDest)=0;
  140.    virtual void DBEXPORT VarSetStringLen(DBaseVar*, int)=0;
  141.    virtual char* DBEXPORT VarGetStringBuffer(DBaseVar*)=0;
  142.  
  143.    virtual DBEXTERR DBEXPORT VarSetProperty(DBaseVar* pObject, char *pPropName,
  144.             DBaseVar* pNewVal )=0;
  145.  
  146.    virtual DBEXTERR DBEXPORT VarSetElement(DBaseVar* pArray, int iDimCount,
  147.             DBaseVar** ppParams, DBaseVar* pNewVal)=0;
  148.  
  149.    virtual DBEXTERR DBEXPORT VarSetCodeBlock(DBaseVar *pSrc, char*)=0;
  150.  
  151.    //
  152.    // Sets the contents of Variable pSrc from Variable pDest
  153.    //
  154.    virtual void DBEXPORT VarSetVar(DBaseVar *pDest, DBaseVar *pSrc)=0;
  155.  
  156. };
  157.  
  158.  
  159. //
  160. // The function 'DBase()' returns the address of the running instance's
  161. //  DBaseExtension pointer.  This pointer in the 16 bit version is stored at
  162. //  offset 0x40 in the stack segment (executable data segment).
  163. //
  164. // 32 bit versions of dBASE will use a different mechanism, code will be
  165. //  recompilable.
  166. //
  167. #define EXT_PTR   0x30
  168.  
  169. static DBaseExtension* DBase(){
  170.    DBaseExtension *pRet;
  171.  
  172.    _asm {
  173.       mov ax,ss:[EXT_PTR]
  174.       mov dx,ss:[EXT_PTR+2]
  175.       mov word ptr pRet,ax
  176.       mov word ptr pRet+2,dx
  177.    }
  178.    return pRet;
  179. }
  180.  
  181. #define __DBASEEXT_H__
  182. #endif
  183.